package io;

import java.io.*;
import java.text.MessageFormat;

public class MxSerializable implements Serializable {

    private static long serialVersionUID = 1L;

    private int num;

    public MxSerializable(int num) {
        this.num = num;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public void writeObject() throws IOException {
        ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(MessageFormat.format("target/serializable/{0}", String.valueOf(this.hashCode()))));
        os.writeObject(this);
        os.close();
    }

    public static MxSerializable readObject(int name) throws IOException, ClassNotFoundException {
        ObjectInputStream os = new ObjectInputStream(new FileInputStream(MessageFormat.format("target/serializable/{0}", String.valueOf(name))));
        return (MxSerializable) os.readObject();
    }
}
